package com.lizhi.yun.deploy.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * @Author: lizhi
 * @Description:
 * @Date: create in 2020/12/21 11:20
 */
@Configuration
@EnableWebSecurity
public class ActuatorSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        //对actuator监控所用的访问全部需要认证
        http.csrf().disable();
        http.authorizeRequests()
                .antMatchers("/**/actuator/**").authenticated()
                .anyRequest().permitAll()
                .and().httpBasic();
    }
}
